def isValid(s: str):
    aList = []  # 当作栈存储括号
    for i in s:
        if i in '([{':
            aList.append(i)
        elif i in ')]}':  # 需要出栈对比
            temp = aList.pop()
            if not ((i == ')' and temp == '(') or (i == ']' and temp == '[') or (i == '}' and temp == '{')):
                return False
    if len(aList) == 0:
        return True

if __name__ == '__main__':
    print(isValid("()"))